﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="chart.aspx.cs" Inherits="ByteSite.Web.admin.form.chart" ValidateRequest="false" %>
<%@ Import namespace="ByteSite.Common" %>

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,initial-scale=1.0,user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<title>数据管理</title>
<link rel="stylesheet" type="text/css" href="../skin/default/style.css" />
<link href="../skin/uikit/css/uikit.min.css" rel="stylesheet" />
<script type="text/javascript" src="../skin/uikit/js/uikit.min.js"></script>
<script type="text/javascript" src="../skin/uikit/js/uikit-icons.min.js"></script>
<script type="text/javascript" src="../../scripts/jquery/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="../../scripts/xm-select/xm-select.js"></script>
<script type="text/javascript" src="../../scripts/jquery/jquery.lazyload.min.js"></script>
<script type="text/javascript" charset="utf-8" src="../js/laymain.js"></script>
<script type="text/javascript" charset="utf-8" src="../js/common.js"></script>
<script type="text/javascript" charset="utf-8">
    function saveSort() {
        var arrayObj = new Object();
        arrayObj.form_id = <%=this.form_id %>;
        arrayObj.list = new Array();
        $("#datatable tbody tr").each(function () {
            var id = $(this).find(".hidId").val();
            var sort_id = $(this).find(".txtSortId").val();
            var obj = { id: id, sort_id: sort_id };
            arrayObj.list.push(obj);
        })
        $.post("/tools/admin_ajax.ashx?action=sort_save", { data: JSON.stringify(arrayObj) }, function (obj) {
            var result = eval("(" + obj + ")");
            if (result.status == 0) {
                UIkit.notification({
                    message: result.msg,
                    status: 'primary',
                    pos: 'top-center',
                    timeout: 2000
                });
                setTimeout(function () {
                    location = location;
                }, 2000);
            } else {
                UIkit.notification({
                    message: result.msg,
                    status: 'danger',
                    pos: 'top-center',
                    timeout: 2000
                });
            }
        })
    }
    function deleteData() {
        var arrayObj = new Object();
        arrayObj.form_id = <%=this.form_id %>;
        arrayObj.list = new Array();
        $("#datatable tbody tr").each(function () {
            var id = $(this).find(".hidId").val();
            var selected = $(this).find(".row-check").is(":checked");
            var obj = { id: id };
            if (selected) {
                arrayObj.list.push(obj);
            }
        })
        $.post("/tools/admin_ajax.ashx?action=data_delete", { data: JSON.stringify(arrayObj) }, function (obj) {
            var result = eval("(" + obj + ")");
            if (result.status == 0) {
                UIkit.notification({
                    message: result.msg,
                    status: 'primary',
                    pos: 'top-center',
                    timeout: 2000
                });
                setTimeout(function () {
                    location = location;
                }, 2000);
            } else {
                UIkit.notification({
                    message: result.msg,
                    status: 'danger',
                    pos: 'top-center',
                    timeout: 2000
                });
            }
        })
    }
</script>
</head>

<body class="mainbody">
<form id="form1" runat="server">


<!--工具栏-->
<div class="uk-grid-match uk-child-width-auto uk-flex-between uk-grid">
    <div class="uk-first-column">
        <div class="uk-panel">
            <div class="uk-button-group uk-first-column">
                <a class="uk-button uk-button-default" uk-icon="check" href="javascript:;" onclick="checkAll(this);" uk-tooltip="全选"></a>
                <a class="uk-button uk-button-default" uk-icon="plus" href="data_edit.aspx?form_id=<%=this.form_id %>&action=<%=DTEnums.ActionEnum.Add %>" uk-tooltip="新增"></a>
                
                <a class="uk-button uk-button-default" uk-icon="cloud-upload" href="javascript:;" onclick="saveSort();" uk-tooltip="保存"></a>
                <a class="uk-button uk-button-default" uk-icon="trash" href="javascript:;" onclick="deleteData();" uk-tooltip="删除"></a>
            </div>
        </div>
    </div>
    <div>
        <div class="uk-panel">
            <div class="uk-margin" uk-margin>
                <asp:TextBox ID="txtKeywords" runat="server" CssClass="uk-input uk-form-width-medium" />
                <asp:LinkButton ID="lbtnSearch" runat="server" CssClass="uk-button uk-button-default" onclick="btnSearch_Click" uk-icon="search"></asp:LinkButton>
            </div>
        </div>
    </div>
</div>
<!--/工具栏-->

<!--列表-->
<div class="table-container">
    <table id="datatable" width="100%" border="0" cellspacing="0" cellpadding="0" class="uk-table uk-table-striped uk-table-justify uk-table-middle uk-table-hover uk-table-divider">
        <thead>
            <tr>
                <th>选择</th>
                <th class="uk-text-left">标题</th>
                <%
                    if (fieldList != null)
                    {
                        foreach (ByteSite.Entitys.dt_form_attribute_field field in fieldList)
                        {
                                        %>
                                <th><%=field.title %></th>
                                <%
                        }
                    }
                    %>
                <th>发布时间</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
    <%if (table != null)
    {
        if (table.Rows.Count > 0)
        {
            foreach (System.Data.DataRow dr in table.Rows)
            {
                            %>
            <tr>
                <td align="center">
                    <span class="checkall uk-checkbox"><input type="checkbox" class="row-check" id="chkId_<%=dr["id"]%>" name="chkId_<%=dr["id"]%>" /></span>
                    <input type="hidden" class="hidId" id="hidId_<%=dr["id"]%>" name="hidId_<%=dr["id"]%>" value="<%=dr["id"]%>" />
                </td>
                <td class="uk-text-left"><a href="data_edit.aspx?action=<%=DTEnums.ActionEnum.Edit %>&form_id=<%=form_id%>&id=<%=dr["id"]%>"><%=dr["data_name"]%></a></td>
                <%
                if (fieldList != null)
                {
                    foreach (ByteSite.Entitys.dt_form_attribute_field field in fieldList)
                    {
                                    %>
                                <td><%=dr[field.name]%></td>
                                <%
                    }
                }
                %>
                <td><%=string.Format("{0:g}", dr["add_time"])%></td>
                <td>
                    <input id="txtSortId_<%=dr["id"]%>" name="txtSortId_<%=dr["id"]%>" class="uk-input uk-form-width-xsmall txtSortId" onkeydown="return checkNumber(event);" value="<%=dr["sort_id"]%>" />
                <td align="center">
                    <a href="data_edit.aspx?action=<%=DTEnums.ActionEnum.Edit %>&form_id=<%=form_id%>&id=<%=dr["id"]%>">修改</a>
                </td>
            </tr>
            
           <%
            }
        }
        else
        {
            if (fieldList != null)
            {
                %><tr><td colspan="<%=(fieldList.Count + 5) %>">暂无记录</td></tr><%
            }
            else
            {
                %><tr><td colspan="5">暂无记录</td></tr><%
            }
        }
    }
    else
    {
        if (fieldList != null)
        {
        %><tr><td colspan="<%=(fieldList.Count + 5) %>">暂无记录</td></tr><%
        }
        else
        {
            %><tr><td colspan="5">暂无记录</td></tr><%
        }
    }
    %>

        </tbody>
    </table>
</div>
<!--/列表-->

<!--内容底部-->
<div class="line20"></div>
<div class="uk-grid-small uk-grid-match uk-child-width-expand uk-grid" uk-grid>
    <div class="uk-width-small uk-first-column">
        <div class="uk-panel">
            <div class="l-btns">
                <asp:TextBox ID="txtPageNum" runat="server" CssClass="uk-input uk-form-width-xsmall" onkeydown="return checkNumber(event);"
                 OnTextChanged="txtPageNum_TextChanged" AutoPostBack="True"></asp:TextBox><span> 条/页</span>
              </div>
        </div>
    </div>
    <div>
        <div class="uk-panel">
            <ul id="PageContent" runat="server" class="uk-pagination"></ul>
        </div>
    </div>
</div>
<!--/内容底部-->

</form>
</body>
</html>
